# -*- coding: utf-8 -*-
"""
@Time    : 2021/10/9 2:40
@Author  : Leibuyun
@File    : 3.2 精确的浮点数运算.py
"""

# 使用decimal模块

from decimal import Decimal, localcontext

if __name__ == '__main__':
    a = Decimal('3.4')
    b = Decimal('2.1')
    print(a + b == Decimal('6.3'))

    with localcontext() as ctx:
        ctx.prec = 3 # 设置本地上下文的小数点保留个数
        print(Decimal('1.3') / Decimal('1.7'))
